package com.ruoyi.car.service.parts.impl;

import com.car.pojo.TbCarMain;
import com.car.pojo.TbPartBatteryPack;
import com.ruoyi.car.mapper.carmanage.TbCarMainMapper;
import com.ruoyi.car.mapper.parts.TbPartBatteryPackMapper;
import com.ruoyi.car.service.parts.ITbPartBatteryPackService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbPartBatteryPackServiceImpl implements ITbPartBatteryPackService {

    @Autowired
    private TbPartBatteryPackMapper tbPartBatteryPackMapper;
    @Autowired
    private TbCarMainMapper tbCarMainMapper;

    @Override
    public List<TbPartBatteryPack> findAll(TbPartBatteryPack tbPartBatteryPack) {
        return tbPartBatteryPackMapper.findAll(tbPartBatteryPack);
    }
    /**
     * 查询
     *
     * @param id
     * @return
     */
    @Override
    public TbPartBatteryPack selectTbPartBatteryPackById(Long id)
    {
        return tbPartBatteryPackMapper.selectTbPartBatteryPackById(id);
    }

    /**
     * 新增
     *
     * @param tbPartBatteryPack
     * @return 结果
     */
    @Override
    public int insertTbPartBatteryPack(TbPartBatteryPack tbPartBatteryPack)
    {
        TbCarMain tbCarMain = tbCarMainMapper.selectTbCarMainById(tbPartBatteryPack.getId());
        tbPartBatteryPack.setCarId(tbCarMain.getId());
        tbPartBatteryPack.setVin(tbCarMain.getVin());
        return tbPartBatteryPackMapper.insertTbPartBatteryPack(tbPartBatteryPack);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param tbPartBatteryPack 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTbPartBatteryPack(TbPartBatteryPack tbPartBatteryPack)
    {
        return tbPartBatteryPackMapper.updateTbPartBatteryPack(tbPartBatteryPack);
    }

    /**
     * 删除【请填写功能名称】对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTbPartBatteryPackByIds(String ids)
    {
        return tbPartBatteryPackMapper.deleteTbPartBatteryPackByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteTbPartBatteryPackById(Long id)
    {
        return tbPartBatteryPackMapper.deleteTbPartBatteryPackById(id);
    }
}
